package com.itc.dispatch.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itc.common.core.domain.R;
import com.itc.common.security.utils.SecurityUtils;
import com.itc.dispatch.domain.FlightOperationMonitoring;
import com.itc.dispatch.domain.SysTagType;
import com.itc.dispatch.domain.TagEntering;
import com.itc.dispatch.service.FlightOperationMonitoringService;
import com.itc.dispatch.service.SysTagTypeService;
import com.itc.dispatch.service.TagEnteringService;
import com.itc.dispatch.mapper.TagEnteringMapper;
import com.itc.system.api.RemoteSystemService;
import com.itc.system.api.domain.SysDept;
import com.itc.system.api.domain.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;
import java.util.stream.Collectors;

/**
* @author 智少
* @description 针对表【tag_entering】的数据库操作Service实现
* @createDate 2024-08-23 11:22:13
*/
@Service
public class TagEnteringServiceImpl extends ServiceImpl<TagEnteringMapper, TagEntering>
    implements TagEnteringService{

    @Autowired
    public SysTagTypeService sysTagTypeService;

    @Autowired
    public FlightOperationMonitoringService flightOperationService;


    @Override
    public R confirm(TagEntering tagEntering) {
        this.baseMapper.insert(tagEntering);
        FlightOperationMonitoring one = flightOperationService.getById(tagEntering.getFlightId());
        if (one == null){
            return R.ok("航班数据不存在");
        }
        one.setTags(tagEntering.getTagName());
        flightOperationService.updateById(one);
        return R.ok("录入成功");
    }

    @Override
    public R<List<String>> getList(TagEntering tagEntering) {
        LambdaQueryWrapper<SysTagType> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.like(tagEntering.getTagName() != null,SysTagType::getTagName,tagEntering.getTagName());
        queryWrapper.like(SysTagType::getDelete,0);
        List<SysTagType> tagTypeList = sysTagTypeService.list(queryWrapper);
        List<String> collectName = tagTypeList.stream().map(SysTagType::getTagName).collect(Collectors.toList());
        return R.ok(collectName);
    }
}




